home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / higemaru.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  4KB  |  153 lines

  1. #include "driver.h"
  2. #include "vidhrdw/generic.h"
  3.  
  4.  
  5.  
  6. static int flipscreen;
  7.  
  8.  
  9. /***************************************************************************
  10.  
  11.   Convert the color PROMs into a more useable format.
  12.  
  13. ***************************************************************************/
  14. void higemaru_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  15. {
  16.     int i;
  17.     #define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
  18.     #define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs])
  19.  
  20.  
  21.     for (i = 0;i < Machine->drv->total_colors;i++)
  22.     {
  23.         int bit0,bit1,bit2;
  24.  
  25.         /* red component */
  26.         bit0 = (*color_prom >> 0) & 0x01;
  27.         bit1 = (*color_prom >> 1) & 0x01;
  28.         bit2 = (*color_prom >> 2) & 0x01;
  29.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  30.         /* green component */
  31.         bit0 = (*color_prom >> 3) & 0x01;
  32.         bit1 = (*color_prom >> 4) & 0x01;
  33.         bit2 = (*color_prom >> 5) & 0x01;
  34.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  35.         /* blue component */
  36.         bit0 = 0;
  37.         bit1 = (*color_prom >> 6) & 0x01;
  38.         bit2 = (*color_prom >> 7) & 0x01;
  39.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  40.  
  41.         color_prom++;
  42.     }
  43.  
  44.     /* color_prom now points to the beginning of the lookup table */
  45.  
  46.     /* characters use colors 0-15 */
  47.     for (i = 0;i < TOTAL_COLORS(0);i++)
  48.         COLOR(0,i) = *(color_prom++) & 0x0f;
  49.  
  50.     color_prom += 128;    /* the bottom half of the PROM doesn't seem to be used */
  51.  
  52.     /* sprites use colors 16-31 */
  53.     for (i = 0;i < TOTAL_COLORS(1);i++)
  54.         COLOR(1,i) = (*(color_prom++) & 0x0f) + 0x10;
  55. }
  56.  
  57.  
  58.  
  59. WRITE_HANDLER( higemaru_c800_w )
  60. {
  61.     if (data & 0x7c) logerror("c800 = %02x\n",data);
  62.  
  63.     /* bits 0 and 1 are coin counters */
  64.     coin_counter_w(0,data & 2);
  65.     coin_counter_w(1,data & 1);
  66.  
  67.     /* bit 7 flips screen */
  68.     if (flipscreen != (data & 0x80))
  69.     {
  70.         flipscreen = data & 0x80;
  71.         memset(dirtybuffer,1,videoram_size);
  72.     }
  73. }
  74.  
  75.  
  76.  
  77. /***************************************************************************
  78.  
  79.   Draw the game screen in the given osd_bitmap.
  80.   Do NOT call osd_update_display() from this function, it will be called by
  81.   the main emulation engine.
  82.  
  83. ***************************************************************************/
  84. void higemaru_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  85. {
  86.     int offs;
  87.  
  88.     /* draw the frontmost playfield. They are characters, but draw them as sprites */
  89.     for (offs = videoram_size - 1;offs >= 0;offs--)
  90.     {
  91.         if (dirtybuffer[offs])
  92.         {
  93.             int sx,sy;
  94.  
  95.             dirtybuffer[offs] = 0;
  96.             sx = offs % 32;
  97.             sy = offs / 32;
  98.             if (flipscreen)
  99.             {
  100.                 sx = 31 - sx;
  101.                 sy = 31 - sy;
  102.             }
  103.  
  104.             drawgfx(tmpbitmap,Machine->gfx[0],
  105.                     videoram[offs] + ((colorram[offs] & 0x80) << 1),
  106.                     colorram[offs] & 0x1f,
  107.                     flipscreen,flipscreen,
  108.                     8*sx,8*sy,
  109.                     0,TRANSPARENCY_NONE,0);
  110.         }
  111.     }
  112.  
  113.     /* copy the background graphics */
  114.     copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  115.  
  116.  
  117.     /* Draw the sprites. */
  118.     for (offs = spriteram_size - 16;offs >= 0;offs -= 16)
  119.     {
  120.         int code,col,sx,sy,flipx,flipy;
  121.  
  122.  
  123.         code = spriteram[offs] & 0x7f;
  124.         col = spriteram[offs + 4] & 0x0f;
  125.         sx = spriteram[offs + 12];
  126.         sy = spriteram[offs + 8];
  127.         flipx = spriteram[offs + 4] & 0x10;
  128.         flipy = spriteram[offs + 4] & 0x20;
  129.         if (flipscreen)
  130.         {
  131.             sx = 240 - sx;
  132.             sy = 240 - sy;
  133.             flipx = !flipx;
  134.             flipy = !flipy;
  135.         }
  136.  
  137.         drawgfx(bitmap,Machine->gfx[1],
  138.                 code,
  139.                 col,
  140.                 flipx,flipy,
  141.                 sx,sy,
  142.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,15);
  143.  
  144.         /* draw again with wraparound */
  145.         drawgfx(bitmap,Machine->gfx[1],
  146.                 code,
  147.                 col,
  148.                 flipx,flipy,
  149.                 sx - 256,sy,
  150.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,15);
  151.     }
  152. }
  153.